﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Jage.Win32
{
    public partial class BusyBox : Form
    {
        public BusyBox()
        {
            InitializeComponent();
        }

        static private BusyBox _busyBox;

        static public void ShowBusy(string text)
        {
            if (_busyBox == null)
            {
                _busyBox = new BusyBox();
                _busyBox.label1.Text = text;
                _busyBox.Show();
                Application.DoEvents();
            }
            else
            {
                throw new ApplicationException("BusyBox is already showing.");
            }
        }

        static public void HideBusy()
        {
            if (_busyBox != null)
            {
                _busyBox.Hide();
                _busyBox = null;
                Application.DoEvents();
            }
            else
            {
                throw new ApplicationException("BusyBox is not showing.");
            }
        }

    }
}
